package com.itcoon.cloud.framework.transform.assemble.handler.clazz;


import com.itcoon.cloud.framework.transform.constants.ComponentOrderConstants;
import com.itcoon.cloud.framework.transform.definition.InjectDefinition;

import java.lang.reflect.Modifier;
import java.util.List;

public class StandardTargetClassHandler implements AssembleForTargetClassHandler {

    @Override
    public boolean support(Class<?> targetPropertyType, Object originGetterValue, List<InjectDefinition> injectInfos) {
        return Modifier.isFinal(targetPropertyType.getModifiers()) || targetPropertyType.isPrimitive() || Number.class.isAssignableFrom(targetPropertyType);
    }

    @Override
    public Object handle(Class<?> targetPropertyType, Object originGetterValue, String[] ignoreProperties, List<InjectDefinition> injectInfos) {
        return originGetterValue;
    }

    @Override
    public int getOrder() {
        return ComponentOrderConstants.ASSEMBLE_HANDLER_MIN + 10;
    }
}
